package com.shy.springframework.test.bean;

import com.shy.springframework.beans.factory.FactoryBean;
import com.shy.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

/**
 * @author yzpang
 * @desc:
 * @date: 2023/2/14 13:44
 */
@Component("mother")
public class HusbandMother implements FactoryBean<IMother> {

    @Override
    public IMother getObject() throws Exception {
        return (IMother) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{IMother.class},
                ((proxy, method, args) -> "婚后妈妈的事务都被婆婆代理了" + method.getName()));
    }

    @Override
    public Class<?> getObjectType() {
        return IMother.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
